package cn.amebius.simpledocker.controller.request;

import cn.amebius.simpledocker.exception.ParameterErrorException;
import lombok.Data;

/**
 * 登录请求
 * @author 阿伟
 * @date 2023/7/27 20:04
 */

@Data
public class LoginRequest {

    //8 ~ 40
    private String username;

    //8 ~ 40
    private String password;

    public void checkParameter() {
        if (username.isEmpty() || password.isEmpty()) {
            throw new ParameterErrorException("账号或密码未填写");
        } else if (username.length() >= 40 || password.length() >= 40){
            throw new ParameterErrorException("账号或密码太长");
        } else if (username.length() < 8 || password.length() < 8) {
            throw new ParameterErrorException("账号或密码太短");
        }
    }
}
